package com.zhuxulin.java.email.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * 计算方面的一些工具
 * 
 * @author ZhuXulin
 * 
 */
public class CalculationUtil {
	/**
	 * 检查日期是否在几天前
	 * @param date 要检查的日期 和当前系统日期比较
	 * @param days 几天内，如果正数表是几天后，负数表是几天前
	 * @return
	 */
	public static boolean isBeforeDays(Date date,int days) {
		System.out.println(date);
		System.out.println(new Date());
		System.out.println(date.before(new Date()));
		if(!date.before(new Date())){
			return false;
		}
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.DATE, days);
		return c.before(new Date());
	}
	public static boolean isInDays(Date date,int days) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.DATE, days);
		return !c.before(new Date());
	}
}
